from datetime import datetime, timedelta
import json
import logging

from django_celery_beat.models import PeriodicTask, ClockedSchedule
from django.core.management.base import BaseCommand
from oscar.core.loading import get_model

from api.tasks import auto_ordered, order_auto_sms, order_check_violation
from api.utils.enums import OrderStatus

LOG = logging.getLogger(__name__)

Order = get_model("order", "Order")
OrderShippingAddress = get_model("order", "Order")


class Command(BaseCommand):
    """
    python3 manage.py order --check-violation
    python3 manage.py order --check-violation-task
    """

    help = "Order"

    def add_arguments(self, parser):
        parser.add_argument("--get", action="store_true", required=False)
        parser.add_argument("--ordered", action="store_true", required=False)

    def handle(self, *args, **options):
        get = options.get("get")
        ordered = options.get("ordered")

        if get:
            LOG.info("test")
        elif ordered:
            auto_ordered(panic_buying_id=268)
